/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.agi.util.fft;


/**
 *
 * @author Renato
 */
public class FftPadrao extends Fft{
    
    private double[] dataRetorno;
    private Complex[] complexData;
    public void calcular(double[] data){
        double inicio=-data[data.length-1]/2;
        for(int i=0;i<data.length;i++){
            complexData[i].setRe(data[i]);
            complexData[i].setIm(0);
        }
        super.calcular(complexData);
        for(int i=0;i<data.length;i++){
            dataRetorno[i]=super.retorno[i].re();
        }
    }
    
    public double[] getData(){
        return dataRetorno;
    }

    public void createDataArea(int size) {
        this.dataRetorno=new double[size];
        complexData=new Complex[size];
        for(int i=0;i<size;i++){
            complexData[i]=new Complex(0,0);
        }
    }
    
    
    public double[] createComplexDatas(){
        double[] complexRetorno=new double[complexData.length];
        for(int i = 0; i<complexData.length; i++){
            complexRetorno[i]=super.retorno[i].re();//*super.retorno[i].re();
            if(complexRetorno[i]<0){
                complexRetorno[i]=-complexRetorno[i];
            }            
            //complexRetorno[i]=Math.sqrt(complexRetorno[i]);
        }
        
        
        
        return complexRetorno;
    }
    public double[] createComplexData(){
        double[] complexRetorno=new double[complexData.length];
        for(int i = 0; i<complexData.length; i++){
            complexRetorno[i]=super.retorno[i].re() * super.retorno[i].im();
            if(complexRetorno[i]<0){
                complexRetorno[i]=-complexRetorno[i];
            }            
            complexRetorno[i]=Math.sqrt(complexRetorno[i]);
        }
        
        
        
        return complexRetorno;
    }
}
